import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/home";
import Layout from "../layout";
// import Cookies from "js-cookie";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index"),
  },
  {
    path: "/dashboard",
    component: Layout,
    children: [
      {
        path: "/dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index"),
        meta: { title: "Dashboard", icon: "el-icon-data-board" },
      },
    ],
  },
  {
    path: "/user",
    component: Layout,
    children: [
      {
        path: "/user",
        name: "User",
        component: () => import("@/views/user/index"),
        meta: { title: "User", icon: "el-icon-user" },
      },
    ],
  },
  {
    path: "/model/:id",
    name: "Model",
    component: () => import("../components/simulation-process/index.vue"),
  },
  {
    path: "*",
    name: "404",
    component: () => import("@/views/404.vue"),
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//     if (to.path === '/' || to.path === '/login') {
//         next()
//     } else {
//         if (Cookies.get('loginStatus')) {
//             next()
//         } else {
//             router.push('/login')
//         }
//     }
// })

export default router;
